/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  @endpointMap = {
    ap-northeast-1 = 'agency.aliyuncs.com',
    ap-northeast-2-pop = 'agency.aliyuncs.com',
    ap-south-1 = 'agency.aliyuncs.com',
    ap-southeast-2 = 'agency.aliyuncs.com',
    ap-southeast-3 = 'agency.aliyuncs.com',
    ap-southeast-5 = 'agency.aliyuncs.com',
    cn-beijing = 'agency.aliyuncs.com',
    cn-beijing-finance-1 = 'agency.aliyuncs.com',
    cn-beijing-finance-pop = 'agency.aliyuncs.com',
    cn-beijing-gov-1 = 'agency.aliyuncs.com',
    cn-beijing-nu16-b01 = 'agency.aliyuncs.com',
    cn-chengdu = 'agency.aliyuncs.com',
    cn-edge-1 = 'agency.aliyuncs.com',
    cn-fujian = 'agency.aliyuncs.com',
    cn-haidian-cm12-c01 = 'agency.aliyuncs.com',
    cn-hangzhou = 'agency.aliyuncs.com',
    cn-hangzhou-bj-b01 = 'agency.aliyuncs.com',
    cn-hangzhou-finance = 'agency.aliyuncs.com',
    cn-hangzhou-internal-prod-1 = 'agency.aliyuncs.com',
    cn-hangzhou-internal-test-1 = 'agency.aliyuncs.com',
    cn-hangzhou-internal-test-2 = 'agency.aliyuncs.com',
    cn-hangzhou-internal-test-3 = 'agency.aliyuncs.com',
    cn-hangzhou-test-306 = 'agency.aliyuncs.com',
    cn-hongkong = 'agency.aliyuncs.com',
    cn-hongkong-finance-pop = 'agency.aliyuncs.com',
    cn-huhehaote = 'agency.aliyuncs.com',
    cn-huhehaote-nebula-1 = 'agency.aliyuncs.com',
    cn-north-2-gov-1 = 'agency.aliyuncs.com',
    cn-qingdao = 'agency.aliyuncs.com',
    cn-qingdao-nebula = 'agency.aliyuncs.com',
    cn-shanghai = 'agency.aliyuncs.com',
    cn-shanghai-et15-b01 = 'agency.aliyuncs.com',
    cn-shanghai-et2-b01 = 'agency.aliyuncs.com',
    cn-shanghai-finance-1 = 'agency.aliyuncs.com',
    cn-shanghai-inner = 'agency.aliyuncs.com',
    cn-shanghai-internal-test-1 = 'agency.aliyuncs.com',
    cn-shenzhen = 'agency.aliyuncs.com',
    cn-shenzhen-finance-1 = 'agency.aliyuncs.com',
    cn-shenzhen-inner = 'agency.aliyuncs.com',
    cn-shenzhen-st4-d01 = 'agency.aliyuncs.com',
    cn-shenzhen-su18-b01 = 'agency.aliyuncs.com',
    cn-wuhan = 'agency.aliyuncs.com',
    cn-wulanchabu = 'agency.aliyuncs.com',
    cn-yushanfang = 'agency.aliyuncs.com',
    cn-zhangbei = 'agency.aliyuncs.com',
    cn-zhangbei-na61-b01 = 'agency.aliyuncs.com',
    cn-zhangjiakou = 'agency.aliyuncs.com',
    cn-zhangjiakou-na62-a01 = 'agency.aliyuncs.com',
    cn-zhengzhou-nebula-1 = 'agency.aliyuncs.com',
    eu-central-1 = 'agency.aliyuncs.com',
    eu-west-1 = 'agency.aliyuncs.com',
    eu-west-1-oxs = 'agency.aliyuncs.com',
    me-east-1 = 'agency.aliyuncs.com',
    rus-west-1-pop = 'agency.aliyuncs.com',
    us-east-1 = 'agency.aliyuncs.com',
    us-west-1 = 'agency.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('agency', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model GetDistributionInfoByUidRequest {
  uid?: long(name='Uid', example='200'),
}

model GetDistributionInfoByUidResponseBody = {
  code?: string(name='Code', description='code', example='200'),
  fxDistributionInfoVO?: {
    bizType?: int32(name='BizType', description='bizType', example='1'),
    distributionRebateType?: int32(name='DistributionRebateType', example='1'),
    level?: int32(name='Level', description='level', example='1'),
    uid?: long(name='Uid', description='uid', example='1223444'),
  }(name='FxDistributionInfoVO'),
  message?: string(name='Message'),
  success?: boolean(name='Success', example='true'),
}

model GetDistributionInfoByUidResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetDistributionInfoByUidResponseBody(name='body'),
}

async function getDistributionInfoByUidWithOptions(request: GetDistributionInfoByUidRequest, runtime: Util.RuntimeOptions): GetDistributionInfoByUidResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.uid)) {
    query['Uid'] = request.uid;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetDistributionInfoByUid',
    version = '2018-03-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getDistributionInfoByUid(request: GetDistributionInfoByUidRequest): GetDistributionInfoByUidResponse {
  var runtime = new Util.RuntimeOptions{};
  return getDistributionInfoByUidWithOptions(request, runtime);
}

model GetFxCustomerRelationByUidRequest {
  uid?: long(name='Uid', description='uid', example='11233'),
}

model GetFxCustomerRelationByUidResponseBody = {
  code?: string(name='Code', description='code', example='200'),
  fxCustomerRelationVO?: {
    customerRebateType?: int32(name='CustomerRebateType', example='1'),
    id?: long(name='Id', description='id', example='123'),
    isDistribution?: int32(name='IsDistribution', example='1'),
    level?: int32(name='Level', description='level', example='1'),
    parentId?: long(name='ParentId', description='parentId', example='1244'),
    parentId1?: long(name='ParentId1', description='parentId1', example='1234'),
    uid?: long(name='Uid', description='uid', example='12224'),
  }(name='FxCustomerRelationVO'),
  message?: string(name='Message', description='message'),
  success?: boolean(name='Success', description='success', example='true'),
}

model GetFxCustomerRelationByUidResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetFxCustomerRelationByUidResponseBody(name='body'),
}

async function getFxCustomerRelationByUidWithOptions(request: GetFxCustomerRelationByUidRequest, runtime: Util.RuntimeOptions): GetFxCustomerRelationByUidResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.uid)) {
    query['Uid'] = request.uid;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetFxCustomerRelationByUid',
    version = '2018-03-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getFxCustomerRelationByUid(request: GetFxCustomerRelationByUidRequest): GetFxCustomerRelationByUidResponse {
  var runtime = new Util.RuntimeOptions{};
  return getFxCustomerRelationByUidWithOptions(request, runtime);
}

model QueryFxCustomerRelationListRequest {
  currentPage?: int32(name='CurrentPage', example='1'),
  customerRebateType?: int32(name='CustomerRebateType', example='1'),
  gmtCreateMax?: string(name='GmtCreateMax'),
  gmtCreateMin?: string(name='GmtCreateMin'),
  isDistribution?: int32(name='IsDistribution', example='1'),
  isRebateAgent?: int32(name='IsRebateAgent', example='1'),
  level?: int32(name='Level', description='level', example='1'),
  pageSize?: int32(name='PageSize', example='1'),
  parentId?: long(name='ParentId', example='123'),
  parentId1?: long(name='ParentId1', description='parent1', example='2321'),
  parentId2?: long(name='ParentId2', description='parent2', example='12233'),
  uid?: long(name='Uid', description='uid', example='1223'),
}

model QueryFxCustomerRelationListResponseBody = {
  code?: string(name='Code', description='code', example='200'),
  count?: int32(name='Count', example='100'),
  data?: {
    fxCustomerRelationVO?: [ 
    {
      customerRebateType?: int32(name='CustomerRebateType', example='1'),
      isDistribution?: int32(name='IsDistribution', example='1'),
      isRebateAgent?: int32(name='IsRebateAgent', example='1'),
      level?: int32(name='Level', description='level', example='1'),
      parentId?: long(name='ParentId', description='parent', example='123'),
      parentId1?: long(name='ParentId1', description='parent1', example='123'),
      parentId2?: long(name='ParentId2', description='parent2', example='123'),
      parentId3?: long(name='ParentId3', description='parentid3', example='123'),
      uid?: long(name='Uid', description='uid', example='123'),
    }
  ](name='FxCustomerRelationVO')
  }(name='Data'),
  message?: string(name='Message', description='msg'),
  requestId?: string(name='RequestId', example='fsdsd'),
  success?: boolean(name='Success', description='success', example='true'),
  totalNum?: int32(name='TotalNum', example='100'),
}

model QueryFxCustomerRelationListResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryFxCustomerRelationListResponseBody(name='body'),
}

async function queryFxCustomerRelationListWithOptions(request: QueryFxCustomerRelationListRequest, runtime: Util.RuntimeOptions): QueryFxCustomerRelationListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.currentPage)) {
    query['CurrentPage'] = request.currentPage;
  }
  if (!Util.isUnset(request.customerRebateType)) {
    query['CustomerRebateType'] = request.customerRebateType;
  }
  if (!Util.isUnset(request.gmtCreateMax)) {
    query['GmtCreateMax'] = request.gmtCreateMax;
  }
  if (!Util.isUnset(request.gmtCreateMin)) {
    query['GmtCreateMin'] = request.gmtCreateMin;
  }
  if (!Util.isUnset(request.isDistribution)) {
    query['IsDistribution'] = request.isDistribution;
  }
  if (!Util.isUnset(request.isRebateAgent)) {
    query['IsRebateAgent'] = request.isRebateAgent;
  }
  if (!Util.isUnset(request.level)) {
    query['Level'] = request.level;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.parentId)) {
    query['ParentId'] = request.parentId;
  }
  if (!Util.isUnset(request.parentId1)) {
    query['ParentId1'] = request.parentId1;
  }
  if (!Util.isUnset(request.parentId2)) {
    query['ParentId2'] = request.parentId2;
  }
  if (!Util.isUnset(request.uid)) {
    query['Uid'] = request.uid;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryFxCustomerRelationList',
    version = '2018-03-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryFxCustomerRelationList(request: QueryFxCustomerRelationListRequest): QueryFxCustomerRelationListResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryFxCustomerRelationListWithOptions(request, runtime);
}

